package geometry;

import geometry.basic.Point;

public abstract class Triangle {

	protected Point a, b, c;

	public Triangle(Point a, Point b, Point c) {
		this.a = a;
		this.b = b;
		this.c = c;
	}

	public abstract boolean contains(Triangle other);

	@Override
	public boolean equals(Object other) {
		if (!(other instanceof Triangle))
			return false;
		Triangle o = (Triangle) other;
		// Might be done faster with a set.
		return equalCorners(o.a, o.b, o.c) || equalCorners(o.b, o.c, o.a)
				|| equalCorners(o.c, o.a, o.b) || equalCorners(o.a, o.c, o.b)
				|| equalCorners(o.c, o.b, o.a) || equalCorners(o.b, o.a, o.c);
	}

	private boolean equalCorners(Point oa, Point ob, Point oc){
		return a.equals(oa) && b.equals(ob) && c.equals(oc);
	}

	@Override
	public int hashCode() {
		return a.hashCode() ^ b.hashCode() ^ c.hashCode();
	}

}
